using System.Collections.Generic;

namespace ActiveRecordSample.Entities
{
	// Business class Customer generated from Customer
	// shvadskd [2008-10-20] Created

	using System;
	using System.ComponentModel;
	using Castle.ActiveRecord;

   [ActiveRecord("SalesLT.Customer")]
	public  class Customer 
		: ActiveRecordValidationBase<Customer> 
	{

		#region Property_Names

		public static string Prop_CustomerID = "CustomerID";
		public static string Prop_NameStyle = "NameStyle";
		public static string Prop_Title = "Title";
		public static string Prop_FirstName = "FirstName";
		public static string Prop_MiddleName = "MiddleName";
		public static string Prop_LastName = "LastName";
		public static string Prop_Suffix = "Suffix";
		public static string Prop_CompanyName = "CompanyName";
		public static string Prop_SalesPerson = "SalesPerson";
		public static string Prop_EmailAddress = "EmailAddress";
		public static string Prop_Phone = "Phone";
		public static string Prop_PasswordHash = "PasswordHash";
		public static string Prop_PasswordSalt = "PasswordSalt";
		public static string Prop_rowguid = "rowguid";
		public static string Prop_ModifiedDate = "ModifiedDate";

		#endregion

		#region Private_Variables

		private int _customerid;
		private bool _nameStyle;
		private string _title;
		private string _firstName;
		private string _middleName;
		private string _lastName;
		private string _suffix;
		private string _companyName;
		private string _salesPerson;
		private string _emailAddress;
		private string _phone;
		private string _passwordHash;
		private string _passwordSalt;
		private DateTime _modifiedDate;

		private IList<Address> _addresses = new List<Address>();
		private IList<SalesOrderHeader> _SalesOrderHeader = new List<SalesOrderHeader>();

		#endregion

		#region Constructors

		public Customer()
		{
		}

		public Customer(
			int p_customerid,
			bool p_nameStyle,
			string p_title,
			string p_firstName,
			string p_middleName,
			string p_lastName,
			string p_suffix,
			string p_companyName,
			string p_salesPerson,
			string p_emailAddress,
			string p_phone,
			string p_passwordHash,
			string p_passwordSalt,		
			DateTime p_modifiedDate)
		{
			_customerid = p_customerid;
			_nameStyle = p_nameStyle;
			_title = p_title;
			_firstName = p_firstName;
			_middleName = p_middleName;
			_lastName = p_lastName;
			_suffix = p_suffix;
			_companyName = p_companyName;
			_salesPerson = p_salesPerson;
			_emailAddress = p_emailAddress;
			_phone = p_phone;
			_passwordHash = p_passwordHash;
			_passwordSalt = p_passwordSalt;			
			_modifiedDate = p_modifiedDate;
		}

		#endregion

		#region Properties

		[PrimaryKey("CustomerID", Access = PropertyAccess.NosetterLowercaseUnderscore)]
		public int CustomerID
		{
			get { return _customerid; }
		}

		[Property("NameStyle", NotNull = true)]
		public bool NameStyle
		{
			get { return _nameStyle; }
			set { _nameStyle = value; }
		}

		[Property("Title", Length = 8)]
		public string Title
		{
			get { return _title; }
			set { _title = value; }
		}

		[Property("FirstName", NotNull = true, Length = 50)]
		public string FirstName
		{
			get { return _firstName; }
			set { _firstName = value; }
		}

		[Property("MiddleName", Length = 50)]
		public string MiddleName
		{
			get { return _middleName; }
			set { _middleName = value; }
		}

		[Property("LastName", NotNull = true, Length = 50)]
		public string LastName
		{
			get { return _lastName; }
			set { _lastName = value; }
		}

		[Property("Suffix", Length = 10)]
		public string Suffix
		{
			get { return _suffix; }
			set { _suffix = value; }
		}

		[Property("CompanyName", Length = 128)]
		public string CompanyName
		{
			get { return _companyName; }
			set { _companyName = value; }
		}

		[Property("SalesPerson", Length = 256)]
		public string SalesPerson
		{
			get { return _salesPerson; }
			set { _salesPerson = value; }
		}

		[Property("EmailAddress", Length = 50)]
		public string EmailAddress
		{
			get { return _emailAddress; }
			set { _emailAddress = value; }
		}

		[Property("Phone", Length = 25)]
		public string Phone
		{
			get { return _phone; }
			set { _phone = value; }
		}

		[Property("PasswordHash", NotNull = true, Length = 128)]
		public string PasswordHash
		{
			get { return _passwordHash; }
			set { _passwordHash = value; }
		}

		[Property("PasswordSalt", NotNull = true, Length = 10)]
		public string PasswordSalt
		{
			get { return _passwordSalt; }
			set { _passwordSalt = value; }
		}

     

		[Property("ModifiedDate", NotNull = true)]
		public DateTime ModifiedDate
		{
			get { return _modifiedDate; }
			set { _modifiedDate = value; }
		}

      [HasAndBelongsToMany(typeof(Address),
        Table = "SalesLT.CustomerAddress", ColumnKey = "CustomerID", ColumnRef = "AddressID",Lazy = true)]
      public IList<Address> Addresses
      {
         get { return _addresses; }
         set { _addresses = value; }
      }
      [HasMany(typeof(SalesOrderHeader), Table = "SalesLT.SalesOrderHeader", ColumnKey = "CustomerID",Inverse = true)]
      public IList<SalesOrderHeader> Orders
      {
         get { return _SalesOrderHeader; }
         set { _SalesOrderHeader = value; }
      }
		#endregion

      public static Customer GetByPrimaryKey(int customerID)
      {
         return FindByPrimaryKey(customerID);
      }

	} // Customer
}

